import request from '@/utils/request'

// 贷后检查管理接口
export const postloanInspectionApi = {
  // 获取贷后检查计划列表
  getList(params) {
    return request({
      url: '/postloan/inspection/list',
      method: 'get',
      params
    })
  },
  
  // 获取贷后检查详情
  getDetail(id) {
    return request({
      url: `/postloan/inspection/detail/${id}`,
      method: 'get'
    })
  },
  
  // 新增贷后检查计划
  add(data) {
    return request({
      url: '/postloan/inspection/add',
      method: 'post',
      data
    })
  },
  
  // 提交贷后检查结果
  submit(data) {
    return request({
      url: '/postloan/inspection/submit',
      method: 'post',
      data
    })
  },
  
  // 上传贷后检查附件
  upload(data) {
    return request({
      url: '/postloan/inspection/upload',
      method: 'post',
      data,
      headers: { 'Content-Type': 'multipart/form-data' }
    })
  },
  
  // 删除贷后检查附件
  deleteAttachment(id) {
    return request({
      url: `/postloan/inspection/attachment/${id}`,
      method: 'delete'
    })
  },
  
  // 删除贷后检查计划
  delete(id) {
    return request({
      url: `/postloan/inspection/${id}`,
      method: 'delete'
    })
  }
}

// 贷后跟踪管理接口
export const postloanTrackApi = {
  // 获取贷后跟踪记录列表
  getList(params) {
    return request({
      url: '/postloan/track/list',
      method: 'get',
      params
    })
  },
  
  // 获取贷后跟踪详情
  getDetail(id) {
    return request({
      url: `/postloan/track/detail/${id}`,
      method: 'get'
    })
  },
  
  // 新增贷后跟踪记录
  add(data) {
    return request({
      url: '/postloan/track/add',
      method: 'post',
      data
    })
  },
  
  // 更新贷后跟踪记录
  update(data) {
    return request({
      url: '/postloan/track/update',
      method: 'put',
      data
    })
  },
  
  // 上传贷后跟踪附件
  upload(data) {
    return request({
      url: '/postloan/track/upload',
      method: 'post',
      data,
      headers: { 'Content-Type': 'multipart/form-data' }
    })
  },
  
  // 删除贷后跟踪附件
  deleteAttachment(id) {
    return request({
      url: `/postloan/track/attachment/${id}`,
      method: 'delete'
    })
  },
  
  // 删除贷后跟踪记录
  delete(id) {
    return request({
      url: `/postloan/track/${id}`,
      method: 'delete'
    })
  }
}

// 贷后评估管理接口
export const postloanAssessmentApi = {
  // 获取贷后评估列表
  getList(params) {
    return request({
      url: '/postloan/assessment/list',
      method: 'get',
      params
    })
  },
  
  // 获取贷后评估详情
  getDetail(id) {
    return request({
      url: `/postloan/assessment/detail/${id}`,
      method: 'get'
    })
  },
  
  // 新增贷后评估
  add(data) {
    return request({
      url: '/postloan/assessment/add',
      method: 'post',
      data
    })
  },
  
  // 更新贷后评估
  update(data) {
    return request({
      url: '/postloan/assessment/update',
      method: 'put',
      data
    })
  },
  
  // 上传贷后评估附件
  upload(data) {
    return request({
      url: '/postloan/assessment/upload',
      method: 'post',
      data,
      headers: { 'Content-Type': 'multipart/form-data' }
    })
  },
  
  // 删除贷后评估附件
  deleteAttachment(id) {
    return request({
      url: `/postloan/assessment/attachment/${id}`,
      method: 'delete'
    })
  },
  
  // 删除贷后评估
  delete(id) {
    return request({
      url: `/postloan/assessment/${id}`,
      method: 'delete'
    })
  }
}

// 贷后预警管理接口
export const postloanWarningApi = {
  // 获取贷后预警列表
  getList(params) {
    return request({
      url: '/postloan/warning/list',
      method: 'get',
      params
    })
  },
  
  // 获取贷后预警详情
  getDetail(id) {
    return request({
      url: `/postloan/warning/detail/${id}`,
      method: 'get'
    })
  },
  
  // 获取预警规则列表
  getRuleList(params) {
    return request({
      url: '/postloan/warning/rule/list',
      method: 'get',
      params
    })
  },
  
  // 新增预警规则
  addRule(data) {
    return request({
      url: '/postloan/warning/rule/add',
      method: 'post',
      data
    })
  },
  
  // 更新预警规则
  updateRule(data) {
    return request({
      url: '/postloan/warning/rule/update',
      method: 'put',
      data
    })
  },
  
  // 删除预警规则
  deleteRule(id) {
    return request({
      url: `/postloan/warning/rule/${id}`,
      method: 'delete'
    })
  },
  
  // 手动添加预警信息
  add(data) {
    return request({
      url: '/postloan/warning/add',
      method: 'post',
      data
    })
  },
  
  // 处理预警信息
  handle(data) {
    return request({
      url: '/postloan/warning/handle',
      method: 'post',
      data
    })
  },
  
  // 上传预警处理附件
  upload(data) {
    return request({
      url: '/postloan/warning/upload',
      method: 'post',
      data,
      headers: { 'Content-Type': 'multipart/form-data' }
    })
  },
  
  // 删除预警处理附件
  deleteAttachment(id) {
    return request({
      url: `/postloan/warning/attachment/${id}`,
      method: 'delete'
    })
  },
  
  // 获取预警统计数据
  getStatistics(params) {
    return request({
      url: '/postloan/warning/statistics',
      method: 'get',
      params
    })
  }
}

// 贷后统计管理接口
export const postloanStatisticsApi = {
  // 获取贷后总体统计数据
  getOverview() {
    return request({
      url: '/postloan/statistics/overview',
      method: 'get'
    })
  },
  
  // 获取检查统计数据
  getInspectionStats(params) {
    return request({
      url: '/postloan/statistics/inspection',
      method: 'get',
      params
    })
  },
  
  // 获取跟踪统计数据
  getTrackStats(params) {
    return request({
      url: '/postloan/statistics/track',
      method: 'get',
      params
    })
  },
  
  // 获取评估统计数据
  getAssessmentStats(params) {
    return request({
      url: '/postloan/statistics/assessment',
      method: 'get',
      params
    })
  },
  
  // 获取预警统计数据
  getWarningStats(params) {
    return request({
      url: '/postloan/statistics/warning',
      method: 'get',
      params
    })
  },
  
  // 获取风险分布统计
  getRiskDistribution(params) {
    return request({
      url: '/postloan/statistics/risk',
      method: 'get',
      params
    })
  },
  
  // 获取贷后工作完成情况统计
  getCompletionStats(params) {
    return request({
      url: '/postloan/statistics/completion',
      method: 'get',
      params
    })
  },
  
  // 获取月度趋势数据
  getMonthlyTrend(params) {
    return request({
      url: '/postloan/statistics/monthly',
      method: 'get',
      params
    })
  },
  
  // 导出统计报表
  exportReport(params) {
    return request({
      url: '/postloan/statistics/export',
      method: 'get',
      params,
      responseType: 'blob'
    })
  }
} 